//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "server\fn_serverSetupActivate.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_object","_action","_instance_id","_parameters","_activated_msg","_deactivated_msg","_shared_variable","_initial_status","_activated_title","_deactivated_title","_activated_code","_deactivated_code"];
DEFAULT_PARAM(_object,TMF_REGISTER_OBJECT,objNull);
DEFAULT_PARAM(_action,TMF_REGISTER_ACTION,[]);
DEFAULT_PARAM(_instance_id,TMF_REGISTER_INSTANCE,TMF_SERVER_INSTANCE_ID);

if (!isnull _object) then {
	_action = [_object,_action_id] call FFUNC(actionGet);
	TRACE_1("Action",_action);
	_parameters = [_action] call FFUNC(actionGetParams);
	_shared_variable = [_parameters, "SHARED_VAR", "",THIS_FILE] call FFUNC(hashGet);
	_initial_status = [_parameters, "SHARED_VAR_VAL", false,THIS_FILE] call FFUNC(hashGet);
	_shared_variable = _shared_variable call FFUNC(getStringVar);

	if (!isNil "_shared_variable") then {
		if (_shared_variable != "") then {
			[_instance_id,_shared_variable,_initial_status] spawn FFUNC(setMissionJIPVar);
			[QGVAR(all_var), [_instance_id,_shared_variable,_initial_status],THIS_FILE] call FFUNC(callEvent);
		};
	};
	_action = [_action, _initial_status] call FFUNC(actionSetEvent);
	[_object, _action] call FFUNC(actionSet);
	_object allowDamage false;
} else {
	ERROR("Object not set");
};

TRACE("End");
TMFPROFILERSTOP;